package com.example.demo.repository;

import com.example.demo.entity.Order;
import com.example.demo.entity.OrderVersion;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface OrderVersionRepository extends JpaRepository<OrderVersion, Long> {
    Optional<OrderVersion> findTopByOrderOrderByVersionDesc(Order order);
    List<OrderVersion> findByOrderOrderByVersionAsc(Order order);
    @Query("SELECT o FROM OrderVersion o  ORDER BY o.id DESC limit 1")
    OrderVersion findLast();
}